package com.blb.thread;

/**
 * 线程优先级
 */
public class ThreadPriorityDemo {


    public static void main(String[] args) {
        Thread thread1 = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
//                if( i == 50){
//                    //当前线程放弃执行
//                    Thread.yield();
//                }
                System.out.println(Thread.currentThread().getName() + "-->" + i);
            }
        });
        Thread thread2 = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                System.out.println(Thread.currentThread().getName() + "-->" + i);
            }
        });
        //设置线程优先级
//        thread1.setPriority(Thread.MIN_PRIORITY);
//        thread2.setPriority(Thread.MAX_PRIORITY);
        thread1.start();
        thread2.start();
    }
}
